import request from "@/axios/request";
import url from "@/axios/url";
const { mesUrl, adminUrl } = url();
// 导出url
export const exportUrl = `${mesUrl}mesProdOtherCode/export`;
export const exportPrintHisUrl = `${mesUrl}mesProdOtherCodePrintHistory/export`;
export const exportClearingRecordUrl = `${mesUrl}mesProdOtherCodeClearLog/export`;

export function getListNew(params = {}) {
  return request({
    url: `${mesUrl}mesProdOrder/selectListNew`,
    method: "get",
    params,
  });
}

// 分页查询
export function getList(params = {}) {
  return request({
    url: `${mesUrl}mesProdOtherCode`,
    method: "get",
    params,
  });
}

// 新增
export function rowCreate(data = {}) {
  return request({
    url: `${mesUrl}mesProdOtherCode`,
    method: "post",
    data,
  });
}
// 修改
export function rowUpdate(data = {}) {
  return request({
    url: `${mesUrl}mesProdOtherCode`,
    method: "put",
    data,
  });
}
// 删除
export function rowDel(id) {
  return request({
    url: `${mesUrl}mesProdOtherCode/${id}`,
    method: "put",
  });
}
// 详情
export function rowDetail(id) {
  return request({
    url: `${mesUrl}mesProdOtherCode/info/${id}`,
    method: "get",
  });
}

// 根据物料查询编码规则
export function selectCommonProduceRelByProduce(params) {
  return request({
    url: `${adminUrl}commonProduceTemplateRel/selectCommonProduceRelByProduce`,
    method: "get",
    params,
  });
}

// 批量生码
export function genCodeBatch(data = {}) {
  return request({
    url: `${mesUrl}mesProdOtherCode/genCodeBatch`,
    method: "post",
    data,
  });
}

// 查询打印条码模板名称列表
export function getBarcodePrintTempList(data = {}) {
  return request({
    url: `${adminUrl}printTemplate/getTempList`,
    method: "post",
    data,
  });
}

// 打印模板详情
export function printTemplateInfo(id = "") {
  return request({
    url: `${adminUrl}printTemplate/info/${id}`,
    method: "get",
  });
}

// 根据工单编码+分类获取其它码生码数量，已打印数量、未打印数量
export function getCodeCount(data = {}) {
  return request({
    url: `${mesUrl}mesProdOtherCode/getCodeCount`,
    method: "POST",
    data,
  });
}

// 查询生产工单可打印其它码数量
export function getGenCountByCodeType(params = {}) {
  return request({
    url: `${mesUrl}mesProdOrder/getGenCountByCodeType`,
    method: "get",
    params,
  });
}

// 检查其它码是否已经生成
export function checkOtherCode(params = {}) {
  return request({
    url: `${mesUrl}mesProdOtherCode/checkOtherCode`,
    method: "get",
    params,
  });
}

// 根据工单编码+分类+数量获取其它码打印明细
export function splitPrintList(params = {}) {
  return request({
    url: `${mesUrl}mesProdOtherCode/splitPrintList`,
    method: "GET",
    params,
  });
}

// 清码
export function clearOtherCode(data = {}) {
  return request({
    url: `${mesUrl}mesProdOtherCode/clearOtherCode`,
    method: "post",
    data,
  });
}

// 根据配置项编码按层级查询
export function selectListByConfigurationCode(params) {
  return request({
    url: `${adminUrl}commonConfigurationItem/selectListByConfigurationCode`,
    method: "get",
    params,
  });
}

// 补打查询-根据工单号+分类获取其它码已打印数量、起始条码、终止条码
export function reprintSel(data = "") {
  return request({
    url: `${mesUrl}mesProdOtherCode/reprintSel`,
    method: "post",
    data,
  });
}

// 补打查询-  根据工单号、分类、起始条码、终止条码获取需要补打的其它码列表
export function reprintSelList(data = "") {
  return request({
    url: `${mesUrl}mesProdOtherCode/reprintSelList`,
    method: "post",
    data,
  });
}

// 新增补打申请
export function addRepairPrint(data = {}) {
  return request({
    url: `${mesUrl}mesProdOtherCodeReprint/insert`,
    method: "post",
    data,
  });
}

// 获取补打其它码-补打申请
export function selectMesProdOthercodeReprintDetail(id) {
  return request({
    url: `${mesUrl}mesProdOtherCodeReprint/selectMesProdOthercodeReprintDetail/${id}`,
    method: "get",
  });
}
// 分页
export function mesProdOthercodeReprint(params = {}) {
  return request({
    url: `${mesUrl}mesProdOtherCodeReprint`,
    method: "get",
    params,
  });
}
// 获取打印次数
export function getPrintingTimes(params) {
  return request({
    url: `${mesUrl}productExtensionProperties/selectOne`,
    method: "get",
    params,
  });
}

// 分页查询 客商
export function getCustomerList(params = {}) {
  return request({
    url: `${adminUrl}commonCustomer`,
    method: "get",
    params,
  });
}
// 查询客商类别编码列表
export function getCustomerTypeValueList() {
  return request({
    url: `${adminUrl}dict/type/customer_type`,
    method: "get",
  });
}
// 查询质检状态列表
export function getQualityTypeList() {
  return request({
    url: `${adminUrl}dict/type/quality_type`,
    method: "get",
  });
}

// 获取补打审核列表
export function getRepairPrintList(params = {}) {
  return request({
    url: `${mesUrl}mesProdOtherCodeReprint`,
    method: "GET",
    params,
  });
}

// 生成打印记录
export function genPrintReport(params = {}) {
  return request({
    url: `${mesUrl}mesProdOtherCode/printOtherBarcode`,
    method: "POST",
    params,
  });
}

// 删除补打申请
export function delRepairReport(id = "") {
  return request({
    url: `${mesUrl}mesProdOtherCodeReprint/${id}`,
    method: "PUT",
  });
}
